home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Gfx / Edit / ImageEngineer / ARexx / batch_convert.rexx next >
OS/2 REXX Batch file  |  1995-03-19  |  3KB  |  101 lines

  1. /* Image Engineer Script                  */
  2. /* Batch convert and render script        */
  3. /* by Simon Edwards                       */
  4. /*                                        */
  5. /* Demonstrates how to use ARexx to batch */
  6. /* load, render, convert and save images. */
  7.  
  8.  
  9. Options results        /* We want results */
  10. options failat 10    /* We want everything >10 to be treated as errors */
  11. signal on error        /* Setup a place for errors to go */
  12.  
  13. address 'IMAGEENGINEER'
  14. 'IE_To_Front'        /* Bring ***** to the front of the display */
  15. 'TYPE 24bit'        /* Set load type */
  16.  
  17.             /* Get some file names from the user */
  18. 'GET_FILES "Select files to convert"'
  19. if RC=5 then exit    /* See if the user cancelled the requester */
  20. MyFileList=RESULT
  21.  
  22.         /* Ask the user how they want to render the images */
  23. 'GET_RENDER COLOUR "Set render options" 0 593920 8 1 256 1 2'
  24. if RC=5 then exit
  25. RenderOptions=RESULT
  26.  
  27.         /* Get the desitination directory from the user */
  28. 'GET_DIR "Select Destination Directory"'
  29. if RC=5 then exit
  30. DestDir=result
  31. endpart=right(DestDir,1)
  32. if endpart~=":" & endpart~="/" then DestDir=DestDir||"/"
  33.  
  34.                 /* get the destination file format */
  35. 'GET_FILE_TYPE "Select Destination File Format"'
  36. If RC=5 then exit
  37. FileType=RESULT
  38.  
  39.         /* Let the user enter a file extension to use */
  40. parse var FileType fileext .
  41. 'GET_STRING "Enter file extension" "Ok|Cancel" ".'||fileext||'"'
  42. if RC=5 then exit
  43. FileExt=RESULT
  44.  
  45.     /* Ask the user if they would like this done in the Background */
  46. 'REQUEST "Shall I do this in the Foreground or Background?" "Fore|Back"'
  47. Fore=RESULT
  48.  
  49. if Fore~=1 then do    /* If we should work in the background then     */
  50. 'WB_TO_FRONT'        /* we need to bring the WB to the front and     */
  51. 'SET_PRI -1'        /* drop our task priority to something friendly */
  52. end
  53.  
  54.         /* Keep going till we run out of files */
  55. do while MyFileList~=""
  56. parse var MyFileList x ';' MyFileList    /* Get the next file name */
  57.  
  58. parse var x ':' temp    /* Extract the file name from the complete path */
  59. if temp="" then temp=x
  60. do forever
  61. parse var temp FileName '/' temp
  62. if temp ="" then break
  63. end
  64.  
  65. 'OPEN "'||x||'"'    /* Open the image */
  66. if RC=5 then exit
  67. Project=RESULT
  68.  
  69. 'SET_RENDER' Project RenderOptions    /* Set up this imges render options */
  70.  
  71. if Fore=1 then do    /* See if we should be quiet or not when rendering */
  72. 'RENDER' Project
  73. end
  74. else do
  75.         /* We're in the background so we should render quietly */
  76. 'RENDER' Project 'QUIET'
  77. end
  78. if RC=5 then exit
  79.  
  80.         /* Save the rendered image */
  81. 'SAVE' Project '"'||destdir||filename||fileext||'" "'||filetype||'"'
  82. if RC=5 then exit
  83. 'CLOSE' Project
  84. end
  85. 'IE_TO_FRONT'
  86. 'SET_PRI 0'
  87. 'REQUEST "All done."'
  88. exit
  89.  
  90. /*******************************************************************/
  91. /* This is where control goes when an error code is returned by IE */
  92. /* It puts up a message saying what happened and on which line     */
  93. /*******************************************************************/
  94. Error:
  95.  
  96. 'IE_TO_FRONT'
  97. 'LAST_ERROR'
  98. 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  99. 'SET_PRI 0'
  100. exit
  101.